﻿using QFramework;

namespace HKTools
{
    public class CMD_AchieveCondition : AbstractCommand
    {
        HK_ConditionType conditionType;
        float delayTime;

        public CMD_AchieveCondition(HK_ConditionType _conditionType, float _delayTime = 0)
        {
            conditionType = _conditionType;
            delayTime = _delayTime;
        }

        protected override void OnExecute()
        {
            if (delayTime > 0)
            {
                ActionKit.Delay(delayTime, () =>
                {
                    this.GetSystem<IHK_TaskSystem>().AchieveCondition(conditionType);
                }).StartGlobal();
            }
            else
            {
                this.GetSystem<IHK_TaskSystem>().AchieveCondition(conditionType);
            }
        }
    }
}